package org.example.model;


import org.example.discount.DiscountStrategy;

public abstract class Fruit {
    protected final double pricePerJin;
    protected DiscountStrategy discountStrategy;

    protected Fruit(double pricePerJin) {
        this.pricePerJin = pricePerJin;
    }

    public void setDiscountStrategy(DiscountStrategy strategy) {
        this.discountStrategy = strategy;
    }

    public double calculatePrice(int weight) {
        double originalPrice = pricePerJin * weight;
        return discountStrategy != null ? 
            discountStrategy.applyDiscount(originalPrice) : originalPrice;
    }
}
